interface ChildPropsType {
  message: string;
  onData: (childData:string) => void
}

export default function Child (props: ChildPropsType) {
  const childMessage = "这是子组件的数据"

  const sendData = () => {
    props.onData(childMessage)
  }

  return (
    <>
      <div className="main">
        <h1>这里是子组件</h1>
        <h2>{ props.message }</h2>
        <button onClick={sendData}>点击传入组件</button>
      </div>
    </>
  )
}
